---@class Battle.SkillData
---@field New fun():Battle.SkillData
local SkillData = Battle.CreateClass("SkillData")
Battle.SkillData = SkillData
function SkillData:ctor(cfgId)
    self.skillId = cfgId
    local cfg = DataTable.GetById("t_skill", cfgId)
    if not cfg then
        logError("找不到技能t_skill " .. cfgId)
        return
    end
    local showCfg = DataTable.GetById("t_skillshow",cfgId)
    if not showCfg then
        logError("找不到技能t_skillshow " .. cfgId)
        return
    end
    self.show = showCfg
    if not string.IsEmpty(self.show.f_CastMagicSE) then
        local param = decodeJsonStrToTable(self.show.f_CastMagicSE)
        self.f_CastMagicSE = {delay = param[1]/1000,res = param[2]}
    end
    self.animNameList = {}
    if not string.IsEmpty(self.show.f_Animation) then
        self.animNameList = string.split(self.show.f_Animation,",")
    end

    self.maxCd = cfg.f_ResetTime / 1000
    self.initCd = cfg.f_FirstResetTime / 1000
    self.during = cfg.f_SkillDuration / 1000
    self.priority = cfg.f_Priority
    self.frontSwingTime = cfg.f_FrontTime / 1000
    self.afterSwingTime = cfg.f_AfterTime / 1000
    self.releaseRadius = cfg.f_ArtDistance / 1000--施法距离
    self.releaseType = cfg.f_ReleaseType--施法方式
    self.skillType = cfg.f_SkillType--
    self.hurtType = cfg.f_HurtType
    self.isFrontSwing = true;--是否已经触发前摇
    self.incidentalBuff = cfg.f_IncidentalBuff
    self.scriptID = cfg.f_ScriptID
    self.f_ScriptParameter = decodeJsonStrToTable(cfg.f_ScriptParameter)
    self.f_SeparateSkill = cfg.f_SeparateSkill
    self.f_BulletID = cfg.f_BulletID
    self.f_AppointTarget = cfg.f_AppointTarget
    self.f_Company = cfg.f_Company
    self.f_UnitType = cfg.f_UnitType
    self.f_TargetRule = cfg.f_TargetRule
    self.f_RepeatChoice = cfg.f_RepeatChoice
    self.f_CalculationAttribute = cfg.f_CalculationAttribute
    self.f_TipsRange = cfg.f_TipsRange
    self.f_HitNode = {}
    self.hitDelayTime = -1
    if not string.IsEmpty(cfg.f_HitNode) then
        self.f_HitNode = decodeJsonStrToTable(cfg.f_HitNode)
        self.hitDelayTime = self.f_HitNode[1]/1000
    end
    if not string.IsEmpty(cfg.f_Charge) then
        local p = decodeJsonStrToTable(cfg.f_Charge)
        self.f_Charge = {type = p[1],distance = p[2]}
    end

    self.interruptList = {}
    if not string.IsEmpty(cfg.f_Interrupt) then
        local param = decodeJsonStrToTable(cfg.f_Interrupt)
        for k,v in pairs(param) do
            self.interruptList[v] = true
        end
    end
    ---@type {type,width,height}
    self.rangeScopeParam = {}
    if not string.IsEmpty(cfg.f_Range) then
        local param  = decodeJsonStrToTable(cfg.f_Range)
        self.rangeScopeParam.type = param[1]
        self.rangeScopeParam.width = param[2]/1000
        if param[3] then
            self.rangeScopeParam.height = param[3]/1000
        end
    end
    self.f_IncidentalBuff = {}
    if not string.IsEmpty(cfg.f_IncidentalBuff) then
        local buffParam = decodeJsonStrToTable(cfg.f_IncidentalBuff)
        for k,v in pairs(buffParam) do
            table.insert(self.f_IncidentalBuff,{type = v[1],buffId = v[2],layer = v[3]})
        end
    end
    self.f_SelfBuff = {}
    if not string.IsEmpty(cfg.f_SelfBuff) then
        local buffParam = decodeJsonStrToTable(cfg.f_SelfBuff)
        for k,v in pairs(buffParam) do
            table.insert(self.f_SelfBuff,{type = v[1],buffId = v[2],layer = v[3]})
        end
    end
    ---@type {type,range,summon}
    self.f_Camp = {}
    if not string.IsEmpty(cfg.f_Camp) then
        local param = decodeJsonStrToTable(cfg.f_Camp)
        self.f_Camp.type = param[1]
        self.f_Camp.range = param[2]
        self.f_Camp.summon = param[3]
    end
    self.f_FixedCalculation = tonumber(cfg.f_FixedCalculation) or 0
    self.f_FixedCorrect = decodeJsonStrToTable(cfg.f_FixedCorrect) or {}
    self.f_Quantity = cfg.f_Quantity

end
